local skill = fk.CreateSkill{
  name = "tea__chengquan",
}
---@type TrigSkelSpec<TrigFunc>
local chengquan = {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skill.name) and target.seat == 1 and target.phase == Player.Finish
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getOtherPlayers(target), function(p)
      return p:inMyAttackRange(target)
    end)
    if #targets > 0 then
      for _, p in ipairs(targets) do
        local use = room:askToUseCard(p, {
          skill_name = skill.name,
          name = "slash",
          pattern = "slash",
          prompt = "#tea__chengquan-use:" .. target.id,
          extra_data = {
            exclusive_targets = {target.id},
            bypass_distances = true,
          }
        })
        if use then
          room:useCard(use)
        else
          p:drawCards(1, self.name)
          if not p:isKongcheng() then
            local cid = room:askToCards(p, {
              min_num = 1,
              max_num = 1,
              skill_name = skill.name,
              cancelable = false,
              prompt = "#tea__chengquan-choose:" .. target.id
            })
            if #cid > 0 then
              room:obtainCard(target, cid, false, fk.ReasonGive)
            end
          end
        end
      end
    end
  end,
}
skill:addEffect(fk.EventPhaseStart, chengquan)
return skill